﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication2
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DropDownList1.Items.Add("广东");
                DropDownList1.Items.Add("广西");
                DropDownList1.Items.Add("福建");
                DropDownList2.Items.Add("深圳");
                DropDownList2.Items.Add("东莞");
                DropDownList2.Items.Add("广州");
            }
        }
        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string province = DropDownList1.SelectedValue;
            DropDownList2.Items.Clear();
            switch (province)
            {
                case "福建":
                    DropDownList2.Items.Add("龙岩");
                    DropDownList2.Items.Add("厦门");
                    DropDownList2.Items.Add("漳州");
                    break;
                case "广东":
                    DropDownList2.Items.Add("深圳");
                    DropDownList2.Items.Add("广州");
                    DropDownList2.Items.Add("东莞");
                    break;
                default:
                    DropDownList2.Items.Add("南宁");
                    DropDownList2.Items.Add("桂林");
                    DropDownList2.Items.Add("崇左");
                    break;
            }

        }


        protected void Button1_Click(object sender, EventArgs e)
        {
            if (FileUpload1.HasFile)
            {
                string url = FileUpload1.FileName;
                if (url.EndsWith(".jpg") || url.EndsWith("jpeg") || url.EndsWith("png"))
                {
                    string newUrl = Server.MapPath("/img/" + url);
                    FileUpload1.SaveAs(newUrl);
                    Image1.ImageUrl = "/img/" + url;
                    Image1.Visible = true;

                }
            }
            Literal1.Text = "用户名："+TextBox1.Text;
            Literal2.Text = "性别："+RadioButtonList1.SelectedValue;
            string str = "你的爱好是：";
            for (int i = 0; i < CheckBoxList1.Items.Count; i++)
            {
                if (CheckBoxList1.Items[i].Selected)
                {
                    str += CheckBoxList1.Items[i].Text + "   ";
                }
            }
            Literal3.Text = str;
            Literal4.Text = $"{DropDownList1.SelectedValue}省，{DropDownList2.SelectedValue}市。";
            Literal5.Text = "其他信息："+ TextBox3.Text;

        }

    }
}